import java.util.Scanner;

public class PrefixSum {//使用一维前缀和
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n = in.nextInt();
        int m = in.nextInt();
        int q = in.nextInt();
        long[][] nums = new long[n + 2][m + 2];
        createMatrix(nums, n, m, in);
        getPrefixSum(nums, n, m);

        while (q > 0) {
            int x1  = in.nextInt();
            int y1  = in.nextInt();
            int x2  = in.nextInt();
            int y2  = in.nextInt();
            long sum = Sum(nums, x1, y1, x2, y2);
            System.out.println(sum);
            q--;
        }

    }

    public static void createMatrix(long[][] nums, int n, int m, Scanner scanner) {//创建矩阵，n + 2行，m + 2列
        // Scanner scanner = new Scanner(System.in);
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                nums[i][j] = scanner.nextLong();
            }
        }
    }

    public static void getPrefixSum(long[][] nums, int n, int m) {//求出每一行的前缀和
        for (int i = 1; i < n + 2; i++) {
            for (int j = 1; j < m + 2; j++) {
                nums[i][j] += nums[i][j - 1];
            }
        }
    }

    public static long Sum(long[][] nums, int x1, int y1, int x2, int y2) {//计算小矩阵的和
        long sum = 0;

        for (int i = x1; i <= x2; i++) {//每一行 最后一个元素相加
            sum += (nums[i][y2] - nums[i][y1 - 1]);
        }

        return sum;
    }
}
